﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.CopsBanditsUI {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import Classes.*;
    import org.aswing.geom.*;
    import Modules.bandits.*;
    import Classes.doobers.*;
    import flash.text.*;
    import org.aswing.event.*;
    import org.aswing.border.*;
    import Display.aswingui.*;
    import L10n.*;

    public class BanditCapturedDialogView extends GenericDialogView {

        public static const TEXT_WIDTH:int = 280;

        protected var m_bandit:BanditData;
        protected var m_cop:Player;

        public function BanditCapturedDialogView(_arg1:Dictionary, _arg2:BanditData, _arg3:Player, _arg4:Boolean=false, _arg5:String="", _arg6:String="", _arg7:Function=null, _arg8:Function=null, _arg9:String=""){
            this.m_bandit = _arg2;
            this.m_cop = _arg3;
            var _local10:int = TYPE_CUSTOM_OK;
            if (_arg4){
                _local10 = TYPE_OK;
            };
            super(_arg1, _arg5, _arg6, _local10, _arg7, "", 0, "", _arg8, _arg9);
        }
        override protected function init():void{
            super.init();
            BanditUtil.logDialogStats("view", "bandit_captured_ui", this.m_bandit);
        }
        override protected function createInteriorHolder():JPanel{
            var _local1:JPanel;
            var _local2:JPanel;
            _local1 = new JPanel(new SoftBoxLayout(SoftBoxLayout.Y_AXIS, 5, AsWingConstants.CENTER));
            _local2 = createHeaderPanel();
            ASwingHelper.prepare(_local2);
            textArea = this.createTextArea();
            ASwingHelper.prepare(textArea);
            _local1.setBorder(new EmptyBorder(null, new Insets(8, 4, 0, 4)));
            _local1.append(_local2);
            _local1.append(ASwingHelper.verticalStrut(15));
            _local1.append(textArea);
            _local1.append(ASwingHelper.verticalStrut(BUTTON_MARGIN));
            var _local3:JPanel = createButtonPanel();
            _local1.append(_local3);
            ASwingHelper.prepare(_local1);
            return (_local1);
        }
        override protected function createTextArea():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER, 2);
            var _local2:JPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
            _local2.setBorder(new EmptyBorder(null, new Insets(0, 20, 0, 0)));
            var _local3:JPanel = this.makeImagePanel();
            var _local4:AssetPane = ASwingHelper.makeMultilineText(m_message, TEXT_WIDTH, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.LEFT, 14, EmbeddedArt.brownTextColor);
            LocaleHelper.localSetting.TextField_adjust((_local4.getAsset() as TextField), {
                embedFonts:false,
                font:EmbeddedArt.SYSTEM_FONT
            });
            LocaleHelper.localSetting.ASwingHelper_setPreferredHeight(_local4, 40);
            _local2.appendAll(_local3, _local4);
            var _local5:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT, 5);
            var _local6:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            var _local7:DisplayObject = m_assetDict["banditIcon"];
            var _local8:AssetPane = new AssetPane(_local7);
            _local6.append(_local8);
            var _local9:JPanel = this.makeRewardPanel();
            _local5.setBorder(new EmptyBorder(null, new Insets(0, 20, 0, 0)));
            _local5.appendAll(_local6, _local9);
            _local1.appendAll(_local2, ASwingHelper.verticalStrut(5), _local5);
            return (_local1);
        }
        protected function makeImagePanel():JPanel{
            var imageAsset:* = null;
            var ap:* = null;
            var jp:* = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            imageAsset = (new (m_assetDict["police_slot_unfilled"])() as DisplayObject);
            if (this.m_cop){
                LoadingManager.load(this.m_cop.snUser.picture, function (_arg1:Event):void{
                    imageAsset = _arg1.target.loader;
                    ap.setAsset(imageAsset);
                });
            };
            ap = new AssetPane(imageAsset);
            jp.append(ap);
            return (jp);
        }
        protected function makeRewardPanel():JPanel{
            var _local3:JPanel;
            var _local4:DisplayObject;
            var _local5:JPanel;
            var _local6:DisplayObject;
            var _local7:AssetPane;
            var _local8:int;
            var _local9:int;
            var _local10:ASColor;
            var _local11:DisplayObject;
            var _local12:JLabel;
            var _local13:JPanel;
            var _local14:DisplayObject;
            var _local15:JLabel;
            var _local16:JPanel;
            var _local17:DisplayObject;
            var _local18:JLabel;
            var _local19:JPanel;
            var _local20:DisplayObject;
            var _local21:JLabel;
            var _local22:JPanel;
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP);
            var _local2:AssetPane = ASwingHelper.makeMultilineCapsText(this.m_bandit.name, 250, EmbeddedArt.TITLE_FONT, TextFormatAlign.LEFT, 15, EmbeddedArt.darkBlueTextColor);
            _local1.appendAll(_local2, ASwingHelper.verticalStrut(5));
            if (this.m_bandit.rewardItems.length > 0){
                _local3 = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
                _local4 = (new (m_assetDict["rewardCard_unlocked"])() as DisplayObject);
                ASwingHelper.setSizedBackground(_local3, _local4, new Insets(0, 26, 6, 26));
                _local5 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                _local6 = m_assetDict["itemReward"];
                _local7 = new AssetPane(_local6);
                ASwingHelper.setForcedSize(_local7, new IntDimension(_local6.width, _local6.height));
                _local8 = ((_local3.getPreferredWidth() / 2) - (_local6.width / 2));
                _local5.appendAll(ASwingHelper.horizontalStrut(_local8), _local7);
                _local9 = ((_local3.getPreferredHeight() / 2) - (_local6.height / 2));
                _local3.appendAll(ASwingHelper.verticalStrut(_local9), _local5);
                _local1.append(_local3);
            } else {
                _local10 = new ASColor(EmbeddedArt.blueTextColor);
                if (this.m_bandit.rewardDooberTotals[Doober.DOOBER_XP] != null){
                    _local11 = (new EmbeddedArt.smallXPIcon() as DisplayObject);
                    _local12 = new JLabel(ZLoc.t("Dialogs", "NumXP", {num:this.m_bandit.rewardDooberTotals[Doober.DOOBER_XP]}));
                    _local12.setFont(ASwingHelper.getBoldFont(14));
                    _local12.setForeground(_local10);
                    _local13 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                    _local13.appendAll(ASwingHelper.horizontalStrut(15), new AssetPane(_local11));
                    _local13.appendAll(ASwingHelper.horizontalStrut(5), _local12);
                    _local1.append(_local13);
                };
                if (this.m_bandit.rewardDooberTotals[Doober.DOOBER_GOODS] != null){
                    _local14 = (new EmbeddedArt.smallGoodsIcon() as DisplayObject);
                    _local15 = new JLabel(ZLoc.t("Dialogs", "NumGoods", {num:this.m_bandit.rewardDooberTotals[Doober.DOOBER_GOODS]}));
                    _local15.setFont(ASwingHelper.getBoldFont(14));
                    _local15.setForeground(_local10);
                    _local16 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                    _local16.appendAll(ASwingHelper.horizontalStrut(15), new AssetPane(_local14));
                    _local16.appendAll(ASwingHelper.horizontalStrut(5), _local15);
                    _local1.append(_local16);
                };
                if (this.m_bandit.rewardDooberTotals[Doober.DOOBER_COIN] != null){
                    _local17 = (new EmbeddedArt.smallCoinIcon() as DisplayObject);
                    _local18 = new JLabel(ZLoc.t("Dialogs", "NumCoins", {num:this.m_bandit.rewardDooberTotals[Doober.DOOBER_COIN]}));
                    _local18.setFont(ASwingHelper.getBoldFont(14));
                    _local18.setForeground(_local10);
                    _local19 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                    _local19.appendAll(ASwingHelper.horizontalStrut(15), new AssetPane(_local17));
                    _local19.appendAll(ASwingHelper.horizontalStrut(5), _local18);
                    _local1.append(_local19);
                };
                if (this.m_bandit.rewardDooberTotals[Doober.DOOBER_ENERGY] != null){
                    _local20 = (new EmbeddedArt.smallEnergyIcon() as DisplayObject);
                    _local21 = new JLabel(ZLoc.t("Dialogs", "NumEnergy", {num:this.m_bandit.rewardDooberTotals[Doober.DOOBER_ENERGY]}));
                    _local21.setFont(ASwingHelper.getBoldFont(14));
                    _local21.setForeground(_local10);
                    _local22 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                    _local22.appendAll(ASwingHelper.horizontalStrut(15), new AssetPane(_local20));
                    _local22.appendAll(ASwingHelper.horizontalStrut(5), _local21);
                    _local1.append(_local22);
                };
            };
            return (_local1);
        }
        override protected function onAccept(_arg1:AWEvent):void{
            super.onAccept(_arg1);
            BanditUtil.logDialogStats("celebrate_with_donuts", "bandit_captured_ui", this.m_bandit);
        }
        override protected function onCancelX(_arg1):void{
            super.onCancelX(_arg1);
            BanditUtil.logDialogStats("X", "bandit_captured_ui", this.m_bandit);
        }

    }
}//package Display.CopsBanditsUI 
